package com.power.sifa.approve.model;


import cn.hutool.core.util.ObjectUtil;
import com.aventrix.jnanoid.jnanoid.NanoIdUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.plf.common.domain.YesNo;
import com.plf.core.common.annotations.FieldEnumText;
import com.plf.core.common.domain.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;

/**
 * 行政复议相关审批表实体类
 */

@Entity
@ApiModel(value = "行政复议相关审批表")
@Data
@Table(name = "Apl_admre_audit", schema = "sfapprove")
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
//@IdClass(Apl_admre_audit.Apl_admre_auditPK.class) 用于复合组件
public class Apl_admre_audit extends BaseModel implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @Setter(AccessLevel.NONE)
    @ApiModelProperty(value = "applyid+type+毫秒")
    private String id;

    @ApiModelProperty(value = "父流程申请id")
    private String applyid;

    /**
     * 行政复议审批表类型常量类
     * {@link com.power.sifa.approve.model.enumeration.Tp_proctype}
     */
    @ApiModelProperty(value = "审批表类型")
    private Integer type;

    @ApiModelProperty(value = "案号")
    private String code;

    @ApiModelProperty(value = "案由")
    private String reason;

    @ApiModelProperty(value = "承办人意见")
    private String firstremark;

    @ApiModelProperty(value = "承办人处理日期")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private String firstdate;

    @ApiModelProperty(value = "承办人id")
    private String firstid;

    @ApiModelProperty(value = "承办人")
    private String firstname;

    @ApiModelProperty(value = "科领导意见")
    private String secondremark;

    @ApiModelProperty(value = "科领导处理日期")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private String seconddate;

    @ApiModelProperty(value = "科领导id")
    private String secondid;

    @ApiModelProperty(value = "科领导")
    private String secondname;

    @ApiModelProperty(value = "局领导意见")
    private String thirdremark;

    @ApiModelProperty(value = "局领导处理日期")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private String thirddate;

    @ApiModelProperty(value = "局领导id")
    private String thirdid;

    @ApiModelProperty(value = "局领导")
    private String thirdname;

    @ApiModelProperty(value = "收到日期")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private String receiptdate;

    @ApiModelProperty(value = "受理日期")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private String acceptdate;

    @ApiModelProperty(value = "期满日期")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private String quedate;

    @ApiModelProperty(value = "申请人")
    private String applyname;

    @ApiModelProperty(value = "被申请人")
    private String targetname;

    @ApiModelProperty(value = "行政复议申请")
    private String admrequest;

    @ApiModelProperty(value = "状态")
    private Integer status;

    @ApiModelProperty(value = "第三人")
    private String thirdper;

    @ApiModelProperty(value = "被申请人是否已答复")
    private Integer istargetreply;

    @ApiModelProperty(value = "是否中止")
    private Integer isrest;

    @ApiModelProperty(value = "是否申请进行调解")
    private Integer ismediate;

    @ApiModelProperty(value = "是否行政不作为")
    private Integer isomission;

    @ApiModelProperty(value = "行政行为类型")
    private Integer prtype;

    @ApiModelProperty(value = "行政管理类别")
    private String mgrcate;

    @ApiModelProperty(value = "程序类型")
    private Integer proctype;

    @ApiModelProperty(value = "是否延期")
    private Integer isdelay;

    @ApiModelProperty(value = "副科领导意见")
    private String fourthremark;

    @ApiModelProperty(value = "副科领导处理日期")
    private String fourthdate;

    @ApiModelProperty(value = "副科领导id")
    private String fourthid;

    @ApiModelProperty(value = "副科领导")
    private String fourthname;

    @ApiModelProperty(value = "分管领导意见")
    private String fiveremark;

    @ApiModelProperty(value = "分管领导处理日期")
    private String fivedate;

    @ApiModelProperty(value = "分管领导id")
    private String fiveid;

    @ApiModelProperty(value = "分管领导")
    private String fivename;

    @ApiModelProperty(value = "受理第一立案审查人id")
    private String acceptfirstid;

    @ApiModelProperty(value = "受理第一立案审查人名称")
    private String acceptfirstname;

    @ApiModelProperty(value = "受理第二立案审查人id")
    private String acceptsecondid;

    @ApiModelProperty(value = "受理第二立案审查人名称")
    private String acceptsecondname;

    @ApiModelProperty(value = "审理第一立案审查人id")
    private String hearfirstid;

    @ApiModelProperty(value = "审理第一立案审查人名称")
    private String hearfirstname;

    @ApiModelProperty(value = "审理第二立案审查人id")
    private String hearsecondid;

    @ApiModelProperty(value = "审理第二立案审查人名称")
    private String hearsecondname;

    @ApiModelProperty(value = "是否市领导审批")
    private Integer iscitymanager = YesNo.NO;

    @ApiModelProperty(value = "是否经过二次审批")
    private Integer issecondout = YesNo.NO;

    @ApiModelProperty(value = "决定类型")
    private Integer decisiontype;

    @ApiModelProperty(value = "决定类型id")
    private Integer decisiontypeid;

    @ApiModelProperty(value = "决定类型名称")
    private String decisiontypename;

    @ApiModelProperty(value = "复议监督部门id")
    private String departid;

    @ApiModelProperty(value = "辅助人id")
    private String assistantid;

    @ApiModelProperty(value = "辅助人名称")
    private String assistantname;


    /**
     * 状态文本
     */
    @Transient
    @FieldEnumText(eum = "", valuefield = "status")
    private String status_text;


    /**
     * 被申请人是否已答复文本
     */
    @Transient
    @FieldEnumText(eum = "yesNo", valuefield = "istargetreply")
    private String istargetreply_text;

    /**
     * 是否申请进行调解文本
     */
    @Transient
    @FieldEnumText(eum = "yesNo", valuefield = "ismediate")
    private String ismediate_text;


    /**
     * 是否行政不作为文本
     */
    @Transient
    @FieldEnumText(eum = "yesNo", valuefield = "isomission")
    private String isomission_text;

    /**
     * 行政行为类型文本
     */
    @Transient
    @FieldEnumText(eum = "Tp_admpr", valuefield = "prtype")
    private String prtype_text;


    /**
     * 程序类型文本
     */
    @Transient
    @FieldEnumText(eum = "Tp_apptype", valuefield = "proctype")
    private String proctype_text;

    /**
     * 是否延期文本
     */
    @Transient
    @FieldEnumText(eum = "yesNo", valuefield = "isdelay")
    private String isdelay_text;

    /**
     * 是否市领导审批文本
     */
    @Transient
    @FieldEnumText(eum = "yesNo", valuefield = "iscitymanager")
    private String iscitymanager_text;

    /**
     * 决定类型文本
     */
    @Transient
    @FieldEnumText(eum = "Tp_decision", valuefield = "decisiontype")
    private String decisiontype_text;

    public Map<String, Object> parseMap() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", this.getId());
        map.put("applyid", this.getApplyid());
        map.put("type", this.getType());
        map.put("code", this.getCode());
        map.put("reason", this.getReason());
        map.put("firstremark", this.getFirstremark());
        map.put("firstdate", this.getFirstdate());
        map.put("firstid", this.getFirstid());
        map.put("firstname", this.getFirstname());
        map.put("secondremark", this.getSecondremark());
        map.put("seconddate", this.getSeconddate());
        map.put("secondid", this.getSecondid());
        map.put("secondname", this.getSecondname());
        map.put("thirdremark", this.getThirdremark());
        map.put("thirddate", this.getThirddate());
        map.put("thirdid", this.getThirdid());
        map.put("thirdname", this.getThirdname());
        map.put("receiptdate", this.getReceiptdate());
        map.put("acceptdate", this.getAcceptdate());
        map.put("quedate", this.getQuedate());
        map.put("applyname", this.getApplyname());
        map.put("targetname", this.getTargetname());
        map.put("admrequest", this.getAdmrequest());
        map.put("status_text", this.status_text);
        map.put("status", this.getStatus());
        map.put("thirdper", this.getThirdper());
        map.put("ismediate_text", this.ismediate_text);
        map.put("ismediate", this.getIsmediate());
        map.put("isomission_text", this.isomission_text);
        map.put("isomission", this.getIsomission());
        map.put("prtype_text", this.prtype_text);
        map.put("prtype", this.getPrtype());
        map.put("mgrcate", this.getMgrcate());
        map.put("proctype_text", this.proctype_text);
        map.put("proctype", this.getProctype());
        map.put("fourthremark", this.getFourthremark());
        map.put("fourthdate", this.getFourthdate());
        map.put("fourthid", this.getFourthid());
        map.put("fourthname", this.getFourthname());
        map.put("acceptfirstid", this.getAcceptfirstid());
        map.put("acceptfirstname", this.getAcceptfirstname());
        map.put("acceptsecondid", this.getAcceptsecondid());
        map.put("acceptsecondname", this.getAcceptsecondname());
        map.put("hearfirstid", this.getHearfirstid());
        map.put("hearfirstname", this.getHearfirstname());
        map.put("hearsecondid", this.getHearsecondid());
        map.put("hearsecondname", this.getHearsecondname());
        return map;
    }

    public String getId() {
        return id;
    }

    public void setId(Serializable id) {
        this.id = (String) id;
    }

    public Serializable getPrimaryKey() {
        return id;
        // return new Apl_admre_auditPK(id, id2); 用于复合主键，请手动创建内部静态类
    }

    public void setPrimaryKey(Serializable key) {
        this.id = (String) key;

        //Apl_admre_auditPK pk = (Apl_admre_auditPK) key; 用于复合主键
        //this.id = pk.getId();
        //this.id2 = pk.getId2();
    }


    public Apl_admre_audit(Apl_main apl_main, Apl_admreview apl_admreview) {
        if (ObjectUtil.isNotEmpty(apl_main) && ObjectUtil.isNotEmpty(apl_admreview)) {
            this.id = NanoIdUtils.randomNanoId();
            this.applyid = apl_main.getId();
            this.code = apl_main.getAcceptcode();
            this.reason = apl_admreview.getReason();
            Calendar c = Calendar.getInstance();
            this.receiptdate = new SimpleDateFormat("yyyy年M月d日").format(c.getTime());
            this.acceptdate = new SimpleDateFormat("yyyy年M月d日").format(c.getTime());
            this.quedate = new SimpleDateFormat("yyyy年M月d日").format(c.getTime());
            ;
            this.applyname = apl_admreview.getApplyname();
            this.targetname = apl_admreview.getTargetname();
            this.admrequest = apl_admreview.getAdmrequest();
            this.status = apl_admreview.getStatus();
            this.thirdper = apl_admreview.getThirdname();
            this.istargetreply = apl_admreview.getIstargetreply();
            this.isrest = apl_admreview.getIsrest();
            this.ismediate = apl_admreview.getIsmediate();
            this.isomission = apl_admreview.getIsomission();
            this.prtype = apl_admreview.getPrtype();
            this.mgrcate = apl_admreview.getMgrcate();
            this.proctype = apl_admreview.getProctype();
            this.isdelay = apl_admreview.getIsdelay();
        }
    }
}
